package com.atguigu.controller;

import com.atguigu.pojo.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

@RestController//@Controller+@ResponseBody
public class TestRestController {
    @RequestMapping("test/rest/ajax")
    public List<User> testAjax(){
        User user1 = new User(1001, "张三", "123", 33, "男");
        User user2 = new User(1002, "王三", "123", 34, "女");
        User user3 = new User(1003, "李三", "123", 35, "女");
        User user4 = new User(1004, "赵三", "123", 23, "男");
        List<User> users = Arrays.asList(user1, user2, user3, user4);

        return users;
    }
    @RequestMapping("test/rest/axios")
    public Object testAxios(){
        HashMap<String, Object> result = new HashMap<>();

        User user1 = new User(1001, "张三", "123", 33, "男");
        User user2 = new User(1002, "王三", "123", 34, "女");
        User user3 = new User(1003, "李三", "123", 35, "女");
        User user4 = new User(1004, "赵三", "123", 23, "男");
        List<User> users = Arrays.asList(user1, user2, user3, user4);

        result.put("msg","ok");
        result.put("data",users);
        result.put("code",200);

        return result;
    }
}
